//
//  ZToastView.swift
//  ZPlayer
//
//  Created by zuber on 2018/11/15.
//  Copyright © 2018年 zuber. All rights reserved.
//

import UIKit

class ZToastView: UIView {

  private lazy var imageView: UIImageView = {
    let iv = UIImageView()
    return iv
  }()
  
  private var valueLabel: UILabel = {
    let label = UILabel()
    label.textColor = UIColor.white
    label.font = UIFont.systemFont(ofSize: 14)
    return label
  }()
  
  var value: String = "" {
    didSet{
      valueLabel.text = value
    }
  }
  
  var image: UIImage? {
    didSet{
      imageView.image = image
    }
  }
  
  override init(frame: CGRect) {
    super.init(frame: frame)
    self.prepareView()
  }
  
  required init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
    self.prepareView()
  }
  
  func prepareView(){
    layer.cornerRadius = 4
    layer.masksToBounds = true
    backgroundColor = UIColor.black.withAlphaComponent(0.5)
    addSubview(imageView)
    addSubview(valueLabel)
    
    imageView.snp.makeConstraints { (make) in
      make.centerX.equalToSuperview()
      make.top.equalToSuperview().offset(10)
    }
    valueLabel.snp.makeConstraints { (make) in
      make.centerX.equalToSuperview()
      make.bottom.equalToSuperview().inset(10)
    }
  }
  
}
